<template>
    <div class="list-page">
        <tool-bar nav="" title="Git服务器">
            <el-button @click="add_click()">添加</el-button>
        </tool-bar>
        <my-list
            ref="list"
            url="/dev/git-server/list"
            @param="preload"
            @loaded="procData"
            :page-size="10"
            store
            draggable
            delete-url="/dev/git-server/delete/{id}"
        >
            <el-table-column label="类型" align="center" width="160">
                <template v-slot="scope">
                    <el-tag v-if="scope.row.gitServerType == 'Gitea'">{{ scope.row.gitServerType }}</el-tag>
                    <el-tag v-else effect="dark" type="warning">{{ scope.row.gitServerType }}</el-tag>
                </template>
            </el-table-column>
            <el-table-column label="名称" align="center" prop="name" sortable="custom">
                <template v-slot="scope">
                    <div class="link" @click="edit_click(scope.row)">{{ scope.row.name }}</div>
                </template>
            </el-table-column>
            <el-table-column align="left" label="地址" prop="host" sortable="custom"></el-table-column>
            <el-table-column align="left" label="备注" prop="remark"></el-table-column>

            <template #query="scope">
                <kv label="名称">
                    <el-input v-model="scope.query.name"></el-input>
                </kv>
            </template>
        </my-list>
    </div>
</template>

<script setup>



//定义 vue2的this,当前组件
let $self = getCurrentInstance();

//定义 $attrs
let $attrs = useAttrs()


//定义事件
let $emit = defineEmits(["update:modelValue","loaded"]);

//定义属性
var $props = defineProps({
    query: {
        type: Object, default() {
            return {};
        }
    }
});

//定义data
let $data = reactive({loading:false})


const preload = function (param) {
    //添加查询参数，修改分页参数等。
    //param.type = jv.$route.params.type
}
//处理列表的数据

const procData = function (res) {
    res.data.data.forEach(it => {
        //如果是组合实体，设置 it.id=...
    });
}
const add_click = function () {
    jv.$router.push("/dev/git-server/add")
}
const edit_click=function ( row) {
    //记录上次点击行
    var rowId = row.id;

    jv.$router.push("/dev/git-server/edit/" + rowId)
}
</script>